<template>
  <van-search name="search" show-action placeholder="请输入搜索关键词" shape="round" maxlength="10" @focus="$router.push('/search')">
    <template #left>
      <van-icon class="left-val" name="bars" @click="LeftMenuRef.showMenu = true" />
    </template>
    <template #action>
    </template>
  </van-search>

  <LeftMenu ref="LeftMenuRef"></LeftMenu>

  <!-- 轮播 -->
  <div class="card home-card">
    <Banner class="banner"></Banner>

    <div class="navBar">
      <li v-for="item, index in navBarList" :key="index">
        <div class="item">
          <van-icon :name="item.icon" size="25" />
        </div>
        <p>{{ item.name }}</p>
      </li>
    </div>

    <!-- 推荐歌单 -->
    <MusicTitle title="推荐歌单" :showMore="true" moreLink="/music" />
    <HotMusic class="hot-music"></HotMusic>


    <!-- 歌曲列表 -->
    <MusicTitle title="最新歌曲推荐" :showMore="false">
      <template #btn>
        <van-button size="mini" type="primary" plain round icon="play" @click="songListRef.playSong()">播放全部</van-button>
      </template>
    </MusicTitle>
    <SongList ref="songListRef"></SongList>


    <!-- 新歌速递 -->
    <!-- <MusicTitle title="新歌速递" :showMore="false"></MusicTitle>
    <NewMusic></NewMusic> -->
  </div>
</template>

<script setup>
import { reactive, toRefs, ref } from 'vue'
import {useRouter} from 'vue-router'
import Banner from '@/components/home/Banner.vue'
import SongList from '@/components/home/SongList.vue'
import HotMusic from '@/components/home/HotMusic.vue'
import MusicTitle from '@/components/home/MusicTitle.vue'
import NewMusic from '@/components/home/NewMusic.vue'
import LeftMenu from '@/components/home/LeftMenu.vue'

const $router = useRouter()
const songListRef = ref();
const LeftMenuRef = ref();

let navBarList = ref([
  {
    name: '每日推荐',
    icon: 'like',
    url: 'day-tui'
  },
  {
    name: '私人FM',
    icon: 'live',
    url: 'FM'
  },
  {
    name: '歌单 ',
    icon: 'service',
    url: 'song-list'
  },
  {
    name: '排行榜',
    icon: 'fire',
    url: 'rank'
  },
  {
    name: '数字专辑',
    icon: 'gift',
    url: 'shuzi'
  },
]);


</script>
  
<style lang='less' scoped>
.home-card {
  border-radius: 0 0 25px 25px;
}

.left-val {
  margin-right: 20px;
}

.navBar {
  width: 100%;
  display: flex;
  flex-wrap: nowrap;
  justify-content: space-around;
  margin-top: 50px;
  text-align: center;

  li {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;

    .item {
      display: flex;
      justify-content: center;
      align-items: center;
      width: 100px;
      height: 100px;
      background-color: #FEF2F2;
      color: #FF5050;
      border-radius: 50%;
    }

    p {
      width: 100%;
      margin-top: 20px;
      font-size: 13px;
    }
  }
}

.hot-music {
  margin-top: 20px
}
</style>